package 面试;

//import lombok.AllArgsConstructor;
//import lombok.Getter;
//import lombok.ToString;

import java.util.concurrent.atomic.AtomicReference;

//@Getter
//@ToString
//@AllArgsConstructor
class user{
    String name;
    int age;
    user(String name, int age){

    }
}

public class AtomicReferenceDemo {

    public static void main(String[] args) {

        user z3 = new user("z3", 16);
        user l4 = new user("l4", 17);

        AtomicReference<user> atomicReference = new AtomicReference<>();
        atomicReference.set(z3);

        System.out.println(atomicReference.compareAndSet(z3, l4) +"\t" + atomicReference.get().toString());
        System.out.println(atomicReference.compareAndSet(z3, l4) +"\t" + atomicReference.get().toString());
    }
}
